function validate(frm) {
	var errmsg = $("errmsgs");
	var err = $("error");

	var errorcount = 0;
	var errmsgs = '';
	
		if(IsBlank(frm.firstname.value)) {
			errmsgs += 'Please enter your\'s first name.<br />';
			errorcount++;
		}
		
		if(IsBlank(frm.business_id.value)) {
			errmsgs += 'URL does not have the business ID. Use correct URL for registration.<br />';
			errorcount++;
		}

		if(IsBlank(frm.lastname.value)) {
			errmsgs += 'Please enter your\'s last name.<br />';
			errorcount++;
		}
			
		if(IsBlank(frm.email.value)) {
			errmsgs += 'Please enter your\'s email address.<br />';
			errorcount++;
		} else if(!checkMail(frm.email.value)) {
			errmsgs += 'Email address is not in proper format.<br />';
			errorcount++;
		}
		
	if(errorcount > 0) {
		errmsg.innerHTML = errmsgs;
		err.style.display = "block";
	} else {
		err.style.display = "none";
	}
	
	if(errorcount == 0 ) {
			return true;
	}
	return false;

}

function checkMail(x) {
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (filter.test(x)) return true;
	else return false;
}

function trim(a) {
	a = a.replace(/^\s+/, '');
	return a.replace(/\s+$/, '');
}

function IsBlank(txt) {
	txt = trim(txt);
	if(txt == "")
		return true;
	else
		return false;
}

function IsNumeric(strString)
   {
   var strValidChars = "0123456789.-,";
   var strChar;
   var blnResult = true;
	
   if (strString.length == 0) return true;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
 }
